#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, k, a[500005];

namespace CR200J {
	int b[500005];
	int dp[1005][1005];
	void main() {
		int minid = 1;
		for (int i = 2; i <= n; ++i) {
			if (a[i] < a[minid]) minid = i;
		}
		for (int i = 1; i <= n; ++i) {
			b[(i - minid + n) % n + 1] = a[i];
		}
		for (int i = 0; i <= n; ++i) {
			for (int j = 0; j <= n; ++j) dp[i][j] = 1ll << 60;
		}
		for (int i = n; i >= 1; --i) {
			for (int j = 0; j <= min(n - i + 1, k); ++j) {
				if (j == 0) {
					dp[i][j] = 0;
					continue;
				}
				int ans = 1ll << 60;
				for (int t = i + 1; t <= n; ++t) {
					ans = min(ans, max(b[i] + b[t], dp[t][j - 1]));
				}
				dp[i][j] = ans;
			}
		}
		cout << dp[1][k - 1] << "\n";
	}
}

namespace BF5033 {
	int b[500005];
	int chk(int x) {
		int lst = 1ll << 60, cnt = 1;
		for (int i = n; i >= 1; --i) {
			if (b[i] + lst <= x) {
				++cnt;
				lst = b[i];
			} else if (b[i] <= lst) lst = b[i];
		}
		return cnt >= k;
	}
	void main() {
		int minid = 1;
		for (int i = 2; i <= n; ++i) {
			if (a[i] < a[minid]) minid = i;
		}
		for (int i = 1; i <= n; ++i) {
			b[(i - minid + n) % n + 1] = a[i];
		}
		int l = -1, r = 1ll << 40;
		while (l + 1 != r) {
			int mid = l + (r - l) / 2;
			if (chk(mid)) r = mid;
			else l = mid;
		}
		cout << r << "\n";
	}
}

signed main() {
	freopen("sub.in", "r", stdin); freopen("sub.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	if (n <= 100) CR200J::main();
	else BF5033::main();
	return 0;
}
